/*
 * Platzad
 * Copyright 2008 Shayne Riley
 *
 * This file is part of Platzad.
 *
 * Platzad is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Platzad is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Platzad.  If not, see <http://www.gnu.org/licenses/>.
 *
 * To contact the authors on questions or issues regarding the license,
 * you may send an email to <shayner at gmail dot com> or write to
 * Shayne Riley / P.O. Box 1092 / McCook, NE 69001.
 */

#ifndef RESLOADER_H_
#define RESLOADER_H_

#include "ImageSDL.h"
#include <string>

namespace pzdUtil
{

//! Resources Loader loads images from files.
class ResLoader
{
    public:
    	//! Constructor for ResLoader
    	/**
    	 * As this class just loads images from files, no options exist at this
    	 * point. Maybe it will become a singleton! It very well could become
    	 * one.
    	 */
    	ResLoader();

        //! Destructor for a class that will never be derived from.
        ~ResLoader();

        //! Reads the contents of the file into a prepared Image.
        /**
         * The file to read from must be a BMP. That's the way it is for now.
         *
         * @param filename the location of the file to read the image from. This
         * 		includes pathnames if needed.
         * @returns the prepared image, or NULL if not loaded correctly,
         * 		a result of not specifying the correct filename, a corrupted
         * 		file, an unreadable file, or not enough memory.
         */
        pzdDisplay::ImageSDL const * readImage(
        		const std::string& filename) const;

    private:

        //! No copying needed, do not allow. Copy ctor declared, not defined.
    	ResLoader(const ResLoader& rhs);
        //! No assignment needed. Do not define this function.
    	ResLoader& operator=(const ResLoader rhs);
        //! No address-of needed. Do not define this function.
    	ResLoader* operator&();
        //! No const address-of needed. Do not define this function.
        const ResLoader* operator&() const;

        // These two methods are hiding out here because they might be useful
        // at a later time.
        //! Copies the contents of an SDL_Surface into another SDL_Surface.
        /**
         * @param src	The source SDL_Surface to copy.
         * @return Another SDL_Surface with a copy of the data.
         */
        SDL_Surface * copySurface(SDL_Surface *src);

        //! Checks to make sure that copying can take place.
        /**
         * The checks are:
         * 1. The source is not null.
         * 2. The source is not locked.
         * 3. SDL_SetVideoMode has a working screen.
         */
        bool copiableSurface(SDL_Surface *src);
};

} // namespace

#endif /*RESLOADER_H_*/
